package org.xg.study.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author CMG
 * @version 1.0
 * @description 通过注解实现Servlet 虚拟路径单一映射
 * @cLassName MyServlet1
 * @date 2021/9/23 14:32
 **/
@WebServlet("/myMapping3")
//@WebServlet(urlPatterns = "/myMapping3") //或者通过此方式
public class MyServletMapp1 extends HttpServlet {
    private static final long serialVersionUID = 1L;

    private int initCount = 0;
    private int httpCount = 0;
    private int destroyCount = 0;

    @Override
    public void destroy() {
        System.out.println(this.getServletName() + ":销毁");
    }

    @Override
    public void init() throws ServletException {
        System.out.println(this.getServletName() + ":初始化完成");
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);
    }
}
